catch babl_{format,model}_new calls with missing parameters
authorNils Philippsen <nils@redhat.com>
Thu, 26 May 2011 13:37:09 +0000 (15:37 +0200)
committerNils Philippsen <nils@redhat.com>
Thu, 26 May 2011 13:37:09 +0000 (15:37 +0200)
babl/babl-format.c
babl/babl-model.c

index 3760452a65948e570e280009c500cba597c0cec3..830d95fdf9f69742a5b737c1f42425288f8b7d2b 100644 (file)
@@ -384,6 +384,20 @@ babl_format_new (void *first_arg,
   if (!name)
     name = create_name (model, components, component, type);
 
+  if (!model)
+    {
+      babl_log ("no model specified for format '%s'", name);
+      babl_free(name);
+      return NULL;
+    }
+
+  if (!components)
+    {
+      babl_log ("no components specified for format '%s'", name);
+      babl_free(name);
+      return NULL;
+    }
+
   babl = babl_db_exist (db, id, name);
   if (id && !babl && babl_db_exist (db, 0, name))
     babl_fatal ("Trying to reregister BablFormat '%s' with different id!", name);
index be2cddeda96f615715ce358331cc96bf0eddb15d..38bbfc3daaa8eeaf805381fa96970916a679696c 100644 (file)
@@ -183,6 +183,13 @@ babl_model_new (void *first_argument,
   else
     name = babl_model_create_name (components, component);
 
+  if (!components)
+    {
+      babl_log("no components specified for model '%s'", name);
+      babl_free(name);
+      return NULL;
+    }
+
   babl = babl_db_exist (db, id, name);
   if (id && !babl && babl_db_exist (db, 0, name))
     babl_fatal ("Trying to reregister BablModel '%s' with different id!", name);